<template>
  <div class="dashboard-container">
    <div class="dashboard-text">name: {{ name }}</div>
  </div>
</template>

<script>
  import {
    mapGetters
  } from 'vuex'

  export default {
    name: 'Dashboard',
    data() {
      return {
        menus: [] //菜单
      }
    },
    computed: {
      ...mapGetters([
        'permission_routes',
        'name'
      ])
    },
    mounted() {
      this.readMenus();
      // console.log("跳转到第一个菜单页");
      // this.toFirst();
    },
    methods: {
      //跳转到第一个菜单页
      toFirst() {
        this.$router.push({
          path: this.menus[0]
        })
      },
      readMenus() {
        for (let r of this.permission_routes) {
          if (!r.hidden) {
            if (r.children && r.children.length > 0) {
              for (let c of r.children) {
                if (!c.hidden) this.menus.push(c.path);
              }
            } else {
              this.menus.push(r.path);
            }
          }
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
  .dashboard {
    &-container {
      margin: 30px;
    }

    &-text {
      font-size: 30px;
      line-height: 46px;
    }
  }
</style>
